<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>会计系统-凭证字设置</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="keywords" content="会计系统-凭证字设置">
<meta name="description" content="会计系统-凭证字设置">
<meta name="author" content="yinqi">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/materialdesignicons.min.css" rel="stylesheet">
<link href="css/style.min.css" rel="stylesheet">
</head>
  <style>
    .col-lg-12{
      margin: auto;
    top: 17px;
    left: 0;
    bottom: 0;
    right: 0;
    position: absolute;
    }
  </style>
<body>
<div class="lyear-layout-web" id="app">
  <div class="lyear-layout-container">
    <!--左侧导航-->

    <!--End 左侧导航-->
    
    <!--头部信息-->
 
    <!--End 头部信息-->
    
    <!--页面主要内容-->

    <main class="lyear-layout-content" >
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12" >
            <div class="card">
              <div class="card-toolbar clearfix">
                <h3 align="center">凭证字设置</h3>
                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5" data-toggle="modal"  data-target="#myModal" ><i class="mdi mdi-plus" ></i> 新增</a>
                  <!-- <el-button  class="btn btn-danger" type="warning" style="background-color:#f96868;" @click="removeBatch(sels)" :disabled="this.sels.length === 0||this.disabled"><i class="mdi mdi-window-close"></i>批量删除</el-button> -->
                </div>
              </div>
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <template>
                      <el-table
                        v-loading="loading"
                        element-loading-text="拼命加载中"
                        :data="list"
                        style="width: 100%">
                        <el-table-column
                          prop="pProof"
                          label="凭证字"
                          width="180">
                        </el-table-column>
                        <el-table-column
                          prop="pTitle"
                          label="打印标题"
                          width="180">
                        </el-table-column>
                        <el-table-column
                          prop="pDefault"
                          label="是否默认"
                          width="180">
                        </el-table-column>
                  <el-table-column label="操作" align="center" min-width="100">
              　　　　<template slot-scope="scope">
                          <div class="btn-group">
                            <a class="btn btn-xs btn-default" @click="edit(scope.row.pId)"  type="button" data-toggle="modal" data-target="#myModalup" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                            <a class="btn btn-xs btn-default" @click="del(scope.row.pId)" type="button"  title="删除" data-toggle="tooltip"><i class="el-icon-close"></i></a>
                          </div>
              　　　　</template>
              　　</el-table-column>
                      </el-table>
                      
                    </template>
                  </table>
                </div>


                <!-- 添加模态框（Modal） -->
                <form action=""  class="form-horizontal" role="form">
                  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                      <div class="modal-dialog">
                          <div class="modal-content">
                              <div class="modal-header">
                                  <h4 class="modal-title" id="myModalLabel">
                                      凭证字新增
                                  </h4>
                                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                      &times;
                                  </button>
                              </div>
                              <div class="modal-body" style="height: 100%;">
                                <div class="form-group">
                                  <label for="lastname" class="col-sm-3 control-label">凭证字</label>
                                  <div class="col-sm-7">
                                    <input class="form-control" type="text" v-model="proof.pProof" placeholder="单位名称">
                                  </div>
                                   </div>
                              <div class="form-group">
                                <label for="lastname" class="col-sm-3 control-label">打印标题</label>
                                <div class="col-sm-7">
                                  <input class="form-control" type="text" v-model="proof.pTitle"  placeholder="凭证字管理权限">
                                </div>
                            </div>
                            <div class="form-group">
                              <label for="lastname" class="col-sm-3 control-label">是否默认</label>
                              <div class="col-sm-7">
                                <template>
                                  <el-radio v-model="radio" label="是">是</el-radio>
                                  <el-radio v-model="radio" label="否">否</el-radio>
                                </template>
                              </div>
                          </div>
                                  
                              </div>
                              <div class="modal-footer">
                                  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                  <el-button id="button" data-dismiss="modal"  class="btn btn-default" type="primary" :loading="loading" @click="accountdd()"  >提交</el-button>

                              </div>
                          </div>
                      </div>
                  </div>
                </form>
<!-- 修改模态框（Modal） -->
<form action=""  class="form-horizontal" role="form">
  <div class="modal fade" id="myModalup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
          <div class="modal-content">
              <div class="modal-header">
                  <h4 class="modal-title" id="myModalLabel">
                    编辑凭证字
                  </h4>
                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                      &times;
                  </button>
              </div>
              <div class="modal-body" style="height: 100%;">
                   <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">凭证字</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" v-model="proof.pProof" placeholder="单位名称">
                    </div>
                     </div>
                     <!-- <div class="form-group">
                      <label for="lastname" class="col-sm-3 control-label">当前记账年份</label>
                      <div class="col-sm-7">
                        <input class="form-control" type="text" v-model="user1.ztCdate" placeholder="当前记账年份">
                      </div>
                  </div> -->
                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">打印标题</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" v-model="proof.pTitle" placeholder="凭证字启用年份">
                    </div>
                </div>
                <div class="form-group" id="sfyc">
                  <label for="lastname" class="col-sm-3 control-label">是否默认</label>
                  <div class="col-sm-7">
                    <template>
                      <el-radio v-model="proof.pDefault" label="是">是</el-radio>
                      <el-radio v-model="proof.pDefault" label="否">否</el-radio>
                    </template>
                  </div>
                  
              </div>
              <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                  <el-button id="button" data-dismiss="modal"  class="btn btn-default" type="primary" :loading="loading" @click="accountup()">提交</el-button>

              </div>
          </div>
      </div>
  </div>
</form>
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.6.9/vue.min.js"></script>
<script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script>

<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>

<script>
  new Vue({
    el:"#app",
  data:{
    radio:"否",
    list:[],
    menu:[],
    proof:{},
    loading: false,
    account:{},
    disabled:true,
    user:{},
    user1:{},
    roleid:"",
    menuup:{}
  },
  created () {
    this.getlist();
  },
  methods: {
    getlist(){
      this.loading=true;
      setTimeout(() => {
      this.loading = false;
      axios.get("http://localhost:8888/proof/selectByExample")
      .then(res => {
         this.list = res.data
        console.log(res)
      })
      .catch(err => {
        console.error(err); 
      })

       }, 2000);
    },
    accountdd(){
     this.proof.pDefault=this.radio
      axios.post("http://localhost:8888/proof/insert",this.proof)
      .then(res => {
        console.log(res)

        this.loading=true;
       setTimeout(() => {
        this.loading = false;

        this.$message({
        message: '恭喜你，凭证字新增成功！！',
        type: 'success'
        });

      }, 2000);
      this.getlist(1);
      })
      .catch(err => {
        console.error(err); 
        this.$message.error('凭证字新增失败！！！');
      })

    },
    accountup(){
      axios.post("http://localhost:8888/proof/proofUpdate",this.proof)
      .then(res => {
        console.log(res)

        this.loading=true;
       setTimeout(() => {
        this.loading = false;

        this.$message({
        message: '恭喜你，凭证字编辑成功！！',
        type: 'success'
        });

      }, 2000);
      this.getlist(1);
      })
      .catch(err => {
        console.error(err); 
        this.$message.error('凭证字编辑失败！！！');
      })
    },
    edit(id){
      axios.get("http://localhost:8888/proof/findByPrimaryKey/"+id)
      .then(res => {
        // alert(JSON.stringify(res.data))
        this.proof = res.data
        console.log(res)
        if("是"==res.data.pDefault){
          $("#sfyc").hide()
        }else{
          $("#sfyc").show()
        }
      })
      .catch(err => {
        console.error(err); 
      })
    },
    del(id){

      this.$confirm('确定要删除凭证字吗?','提示').then(() =>{
        axios.delete("http://localhost:8888/proof/delete/"+id)
      .then(res => {
        console.log(res)

        this.loading=true;
       setTimeout(() => {
        this.loading = false;

        this.$message({
        message: '恭喜你，凭证字删除成功！！',
        type: 'success'
        });
      }, 2000);
      this.getlist(1);
      })
      .catch(err => {
        console.error(err); 
        this.$message.error('凭证字删除失败！！！');
      })
    
      }).catch(()=>{}); 

    }
      
  }
  })
</script>
</body>
</html>